package Iostart;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * Map 的测试类
 * @author AcerMr
 *
 */
public class MapMain
{
	public static void main(String[] args)
	{
		System.out.println("========");
		Map< String, String> map = new HashMap<String ,String >();
		Map<String, String> map1 = new HashMap<String,String>();
		map1.put("NBA", "科比");
		map1.put("NBA1", "詹姆斯");
		map1.put("NBA2", "库里");
		System.out.println(map.size()+"===toString ===="+ map);
		String put = map.put("明朝", "朱元璋");
		System.out.println("====put====" + put);
		put = map.put("北宋", "赵祯");
		put = map.put("南宋", "赵冀");
		map.putAll(map1);
		System.out.println(map.size()+"===toString ===="+ map);
		String value = map.get("明朝");
		System.out.println(value);
		Set<String> KeyName = map.keySet();
		System.out.println("======迭代器=====");
		for(Iterator<String> iter = KeyName.iterator();iter.hasNext();)
		{
			String key1 = iter.next();
			String value1 = map.get(key1);
			System.out.println(key1+"========>"+value1);
		}
		System.out.println("==========Entry的迭代器打印============");
		Set<Map.Entry<String, String>> entryset = map.entrySet();
		for(Iterator<Entry<String,String>> iter = entryset.iterator(); iter.hasNext();)
		{
			Entry<String,String> entry = iter.next();
			String key2 = entry.getKey();
			String value2 = entry.getValue();
			System.out.println(key2+"========>"+value2);
		}
		
	}
}
